package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {

    /**
     * 根据分类id查询套餐的数量
     * @param id
     * @return
     */
    @Select("select count(id) from setmeal where category_id = #{categoryId}")
    Integer countByCategoryId(Long id);

    /**
     * 通过分类id查询套餐
     * @param setmeal
     * @return
     */
    List<Setmeal> getSetmeal(Setmeal setmeal);

    /**
     * 通过id获得套餐简要信息
     * @param id
     * @return
     */
    @Select("select id, category_id, name, price, status, description, image, create_time, update_time, create_user, update_user from setmeal where id = #{id}")
    Setmeal getSetmealById(Long id);

    /**
     * 通过条件查询获得SetmealVO
     * @param setmeal
     * @return
     */
    List<SetmealVO> getSetmealVO(Setmeal setmeal);

    /**
     * 给setmeal插入数据
     * @param setmeal
     */
    @AutoFill(value = OperationType.INSERT)
    void addSetmeal(Setmeal setmeal);

    /**
     * 修改套餐
     * @param setmeal
     */
    @AutoFill(value = OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

    /**
     * 批量删除套餐
     * @param ids
     */
    void deleteSetmeal(List<Long> ids);

    /**
     * 获取停售下的套餐数量
     * @param ids
     * @param disable
     * @return
     */
    int countSetmealByStatusAndIds(List<Long> ids, Integer disable);

    /**
     * 获取指定id套餐的状态
     * @param id
     * @return
     */
    @Select("select status from setmeal where id = #{id}")
    Integer getStatusById(Long id);

    /**
     * 通过状态获取数量
     * @param status
     * @return
     */
    @Select("select count(*) from setmeal where status = #{status}")
    Integer countByStatus(Integer status);
}
